package start;

import com.example.start.PeopleInfo;
import com.google.protobuf.InvalidProtocolBufferException;

import java.util.Arrays;

public class FastStart {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        PeopleInfo peopleInfo = PeopleInfo.newBuilder()
                .setName("张三")
                .setAge(18)
                .setTel("13333333333")
                .build();
        // 序列化
        byte[] bytes = peopleInfo.toByteArray();
        System.out.println("peopleInfo 序列化结果：" + Arrays.toString(bytes));

        // 反序列化
        PeopleInfo peopleInfo1 = PeopleInfo.parseFrom(bytes);
        System.out.println("反序列化结果: ");
        System.out.println("姓名：" + peopleInfo1.getName());
        System.out.println("年龄：" + peopleInfo1.getAge());
        System.out.println("电话：" + peopleInfo1.getTel());
    }
}
